Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports ModuleMasters.DNN.Modules.NCAAPoolStandings.Business

Namespace ModuleMasters.DNN.Modules.NCAAPoolStandings

	Public MustInherit Class NCAAPoolStandingsEdit
		Inherits Entities.Modules.PortalModuleBase

#Region "Controls"
        Protected WithEvents cmdUpdate As System.Web.UI.WebControls.LinkButton
        Protected WithEvents cmdCancel As System.Web.UI.WebControls.LinkButton
        Protected WithEvents cmdDelete As System.Web.UI.WebControls.LinkButton
#End Region

#Region "Private Members"
        Private itemId As Integer
#End Region

#Region "Event Handlers"
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                Dim objCtlNCAAPoolStandings As New NCAAPoolStandingsController
                Dim objNCAAPoolStandings As New NCAAPoolStandingsInfo

                ' Determine ItemId
                If Not (Request.Params("ItemId") Is Nothing) Then
                    itemId = Int32.Parse(Request.Params("ItemId"))
                Else
                    itemId = Null.NullInteger()
                End If

                If Not Page.IsPostBack Then
                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("DeleteItem") & "');")
                    If Not Null.IsNull(itemId) Then
                        'objNCAAPoolStandings = objCtlNCAAPoolStandings.Get(itemId, ModuleId)
                        If Not objNCAAPoolStandings Is Nothing Then
                            'Load data

                            cmdDelete.Visible=True
                        Else ' security violation attempt to access item not related to this Module
                            Response.Redirect(NavigateURL(), True)
                        End If

                    End If
                End If
            Catch exc As Exception
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
            Try
                ' Only Update if the Entered Data is Valid
                If Page.IsValid = True Then
                    Dim objNCAAPoolStandings As New NCAAPoolStandingsInfo

                    objNCAAPoolStandings = CType(CBO.InitializeObject(objNCAAPoolStandings, GetType(NCAAPoolStandingsInfo)), NCAAPoolStandingsInfo)

                    'bind text values to object
                    'objNCAAPoolStandings.ItemId = itemId
                    'objNCAAPoolStandings.ModuleId = ModuleId

                    Dim objCtlNCAAPoolStandings As New NCAAPoolStandingsController
                    If Null.IsNull(itemId) Then
                        'objCtlNCAAPoolStandings.Add(objNCAAPoolStandings)
                    Else
                        'objCtlNCAAPoolStandings.Update(objNCAAPoolStandings)
                    End If

                    ' Redirect back to the portal home page
                    Response.Redirect(NavigateURL(), True)
                End If
            Catch exc As Exception
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
            Try
                Response.Redirect(NavigateURL(), True)
            Catch exc As Exception
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Private Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click
            Try
                If Not Null.IsNull(itemId) Then
                    Dim objCtlNCAAPoolStandings As New NCAAPoolStandingsController
                    'objCtlNCAAPoolStandings.Delete(itemId)
                End If

                ' Redirect back to the portal home page
                Response.Redirect(NavigateURL(), True)
            Catch exc As Exception
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub
#End Region

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

    End Class

End Namespace
